package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchBatchReportTasks;
import com.ruoyi.system.service.IDispatchBatchReportTasksService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 批量填报任务Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchBatchReportTasks")
public class DispatchBatchReportTasksController extends BaseController
{
    @Autowired
    private IDispatchBatchReportTasksService dispatchBatchReportTasksService;

    /**
     * 查询批量填报任务列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchBatchReportTasks:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchBatchReportTasks dispatchBatchReportTasks)
    {
        startPage();
        List<DispatchBatchReportTasks> list = dispatchBatchReportTasksService.selectDispatchBatchReportTasksList(dispatchBatchReportTasks);
        return getDataTable(list);
    }

    /**
     * 导出批量填报任务列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchBatchReportTasks:export')")
    @Log(title = "批量填报任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchBatchReportTasks dispatchBatchReportTasks)
    {
        List<DispatchBatchReportTasks> list = dispatchBatchReportTasksService.selectDispatchBatchReportTasksList(dispatchBatchReportTasks);
        ExcelUtil<DispatchBatchReportTasks> util = new ExcelUtil<DispatchBatchReportTasks>(DispatchBatchReportTasks.class);
        util.exportExcel(response, list, "批量填报任务数据");
    }

    /**
     * 获取批量填报任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchBatchReportTasks:query')")
    @GetMapping(value = "/{batchReportTasksId}")
    public AjaxResult getInfo(@PathVariable("batchReportTasksId") Long batchReportTasksId)
    {
        return success(dispatchBatchReportTasksService.selectDispatchBatchReportTasksByBatchReportTasksId(batchReportTasksId));
    }

    /**
     * 新增批量填报任务
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchBatchReportTasks:add')")
    @Log(title = "批量填报任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchBatchReportTasks dispatchBatchReportTasks)
    {
        return toAjax(dispatchBatchReportTasksService.insertDispatchBatchReportTasks(dispatchBatchReportTasks));
    }

    /**
     * 修改批量填报任务
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchBatchReportTasks:edit')")
    @Log(title = "批量填报任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchBatchReportTasks dispatchBatchReportTasks)
    {
        return toAjax(dispatchBatchReportTasksService.updateDispatchBatchReportTasks(dispatchBatchReportTasks));
    }

    /**
     * 删除批量填报任务
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchBatchReportTasks:remove')")
    @Log(title = "批量填报任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{batchReportTasksIds}")
    public AjaxResult remove(@PathVariable Long[] batchReportTasksIds)
    {
        return toAjax(dispatchBatchReportTasksService.deleteDispatchBatchReportTasksByBatchReportTasksIds(batchReportTasksIds));
    }
}
